// import qs from 'qs'
export default function({ $axios, redirect }) {
  //   $axios.defaults.baseURL = process.env.HOST
  $axios.defaults.headers.post['Content-Type'] =
    'application/x-www-form-urlencoded'
  $axios.onRequest(config => {
    // console.log('发出请求：', config)
    if (config.method === 'post') {
      // config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
      // config.data = qs.stringify(config.data)
    }
  })

  $axios.onError(error => {
    const code = parseInt(error.response && error.response.status)
    if (code === 400) {
      redirect('/400')
    }
  })
}
